package com.yunji.cabinet.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yunji.cabinet.domain.TakeDeliveryDO;
import com.yunji.cabinet.params.RecordParam;
import com.yunji.cabinet.vo.TakeDeliveryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ITakeDeliveryMapper extends MPJBaseMapper<TakeDeliveryDO> {

    @Select("<script> select ttd.*,tms.site_id as siteId,tms.agent_id as agentId from tl_take_delivery ttd " +
            " left join tm_site_location tms on ttd.location_id = tms.location_id where ttd.del_flag =0 and take_status = 1 " +
            " <if test='containerId != null'> and ttd.container_id = #{containerId}  </if>" +
            " <if test='siteId != null'> and tms.site_id = #{siteId} </if>" +
            " <if test='agentId != null'> and tms.agent_id = #{agentId} </if> " +
            " <if test='staffName != null'> and ttd.staff_name like concat('%',#{staffName},'%') </if>" +
            " <if test='locationName != null'> and tms.location_name like concat('%',#{locationName},'%') </if>" +
            " <if test='startTime != null'> and ttd.start_time &gt;= #{startTime} </if>" +
            " <if test='endTime != null'> and ttd.start_time &lt;= #{endTime} </if>" +
            " ${orderSql} </script>")
    List<TakeDeliveryVO> searchPageList(RecordParam param);
}
